package h.framework.pacy.utils;

import android.content.Context;
import android.graphics.Color;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.NinePatchDrawable;
import android.os.Build;
import androidx.annotation.CheckResult;
import androidx.annotation.ColorInt;
import androidx.annotation.DrawableRes;
import androidx.annotation.NonNull;

import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import h.framework.pacy.P;
import h.framework.pacy.R;

import static h.framework.pacy.P.getContext;

/**
 * 创建人 PACY
 * 创建时间 18/11/29 10:26.
 * 邮箱 pengwwe457621023@qq.com
 * 类描述 在系统Toast基础上的封装
 */

public class ToastUtil {

    private static boolean isShow = true;//默认显示
    private static Toast mToast = null;//全局唯一的Toast
    /**
     * 短时间显示Toast
     *
     * @param message
     */
    public static void showShort( CharSequence message) {
        if (isShow){
            if (mToast == null) {
                mToast = Toast.makeText(P.getContext(), message, Toast.LENGTH_SHORT);
                mToast.setGravity(Gravity.CENTER_HORIZONTAL, 0, ScreenUtil.dp2px(200));
                View view=View.inflate(P.getContext(),R.layout.toast_layout,null);
                TextView toast_tv=view.findViewById(R.id.toast_tv);
                toast_tv.setText(message);
                mToast.setView(view);
            } else {
                TextView toast_tv=mToast.getView().findViewById(R.id.toast_tv);
                toast_tv.setText(message);
            }
            mToast.show();
        }
    }





}
